#include "stdio.h"
#include "../section_locate.h"

#include "pt-thread.h"
#include "workqueue.h"

void pt_workque_test(void);

static char name[30] = "pt_workque_test";
struct func_pack sec_pt_workque_test __attribute__ ( ( section ( "func_area" ) ) ) = {
    .func_addr = pt_workque_test,
	.name_str = (uint32_t *)&name,
};


static struct pt_work my_work, my_work2, my_work3;
static void work_func_handler(struct pt_work *work)
{
    static int cnt = 0;
    cnt++;
    if(cnt > 5){
        pt_work_cancel(work);
    }
    printf("work\n");
    printf("work data=%d len=%d\n", (int)work->work_data, work->work_data_len );
}


static void work_func_handler2(struct pt_work *work)
{
    printf("work2\n");
    printf("work data=%d len=%d\n", (int)work->work_data, work->work_data_len );
}
static void work_func_handler3(struct pt_work *work)
{
    static int cnt;
    cnt++;
    printf("work3 cnt:%d\n", cnt);
    printf("work data=%d len=%d\n", (int)work->work_data, work->work_data_len );
}

void pt_workque_test(void)
{



    PT_SCHEDULE_REPEAT_WORK(&my_work, work_func_handler, 3000, 10, (void*)88, 66);


    PT_SCHEDULE_REPEAT_WORK(&my_work2, work_func_handler2, 2000, 20, (void*)44, 22);

    PT_SCHEDULE_REPEAT_WORK(&my_work3, work_func_handler3, 4000, PT_WORK_REPEAT_FOREVER, (void*)90, 57);

}



